package com.htgd.gardenexpo.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.htgd.gardenexpo.entity.CommonResult;
import com.htgd.gardenexpo.entity.GeMyInformation;
import com.htgd.gardenexpo.dao.GeMyInformationDao;
import com.htgd.gardenexpo.page.InformationQuery;
import com.htgd.gardenexpo.service.GeMyInformationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 常用信息表 服务实现类
 * </p>
 *
 * @author author
 * @since 2024-05-21
 */
@Service
public class GeMyInformationServiceImpl extends ServiceImpl<GeMyInformationDao, GeMyInformation> implements GeMyInformationService {

    @Autowired
    private GeMyInformationDao geMyInformationDao;

    @Override
    public PageInfo<GeMyInformation> querylist(InformationQuery informationQuery, String openId) {
        PageHelper.startPage(informationQuery.getPageNum(), informationQuery.getPageSize());
        List<GeMyInformation> list = geMyInformationDao.querylist(informationQuery,openId);
        for (GeMyInformation geMyInformation : list) {
            geMyInformation.setOpenId("");
        }
        return new PageInfo<>(list);
    }

    @Override
    public List<GeMyInformation> getListById(Integer informationId) {
        return lambdaQuery().eq(GeMyInformation::getId,informationId)
                .list();
    }

    @Override
    public CommonResult delete(int id) {
         lambdaUpdate().eq(GeMyInformation::getId,id)
                .set(GeMyInformation::getDeleteFlag,"1")
                .update();
         return CommonResult.success("删除成功");
    }
}
